import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

import { getPaperGetUnitTree } from '/@/api/flowManage/flowManage';
import { isArray } from '/@/utils/is';
import { cloneDeep } from 'lodash-es';

export const columns: BasicColumn[] = [
  {
    title: '编号',
    dataIndex: 'sort',
    key: 'sort',
    width: 100,
  },
  {
    title: '名称',
    dataIndex: 'name',
    key: 'name',
    width: 100,
  },
  {
    title: '部门',
    dataIndex: 'depts',
    key: 'depts',
    width: 150,
  },
  {
    title: '单位',
    dataIndex: 'unitCode',
    key: 'unitCode',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'what',
    label: '名称',
    component: 'Input',
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [];

export const getDepartmentData = async () => {
  return await getPaperGetUnitTree();
};

export const setParams = (data) => {
  const params = cloneDeep(data);
  if (isArray(params['depts'])) {
    params['depts'] = params['depts'].join(',');
  }
  return params;
};
